/*
 * @ : Copyright (c) 2021 Phytium Information Technology, Inc. 
 *  
 * SPDX-License-Identifier: Apache-2.0.
 * 
 * @Date: 2021-08-23 16:24:13
 * @LastEditTime: 2021-08-25 16:10:43
 * @Description:  This files is for 
 * 
 * @Modify History: 
 *  Ver   Who        Date         Changes
 * ----- ------     --------    --------------------------------------
 */

#include "gmac.h"
#include "gmac_hw.h"

GmacConfig gmacConfigTbl[GMAC_INSTANCE_NUM] = 
{
    [GMAC_INSTANCE_0] = {
        .instanceId = GMAC_INSTANCE_0,
        .baseAddr = GMAC_INSTANCE_0_BASE_ADDR,
        .irqNum  = GMAC_INSTANC_0_IRQ,
        .irqPrority = 0,
        .irqName = "GMAC0-IRQ",
        .enableIrq = TRUE,
        .phyAddr = 0,
        .clkMDC = GMAC_MII_ADDR_CR_250_300MHZ,
        .autoNegot = GMAC_AUTONEGOTIATION_ENABLE,
        .speed = GMAC_SPEED_1000,
        .duplexMode = GMAC_MODE_FULLDUPLEX,
        .checkSumMode = GMAC_CHECKSUM_BY_SOFTWARE,
        .mediaInterface = GMAC_MEDIA_INTERFACE_RGMII,
        .macAddr = {0}
    },

    [GMAC_INSTANCE_1] = {
        .instanceId = GMAC_INSTANCE_1,
        .baseAddr = GMAC_INSTANCE_1_BASE_ADDR,
        .irqNum = GMAC_INSTANC_1_IRQ,
        .irqPrority = 0,
        .irqName = "GMAC1-IRQ",
        .enableIrq = TRUE,
        .phyAddr = 0,
        .clkMDC = GMAC_MII_ADDR_CR_250_300MHZ,
        .autoNegot = GMAC_AUTONEGOTIATION_ENABLE,
        .speed = GMAC_SPEED_1000,
        .duplexMode = GMAC_MODE_FULLDUPLEX,
        .checkSumMode = GMAC_CHECKSUM_BY_SOFTWARE,
        .mediaInterface = GMAC_MEDIA_INTERFACE_RGMII,
        .macAddr = {0}
    },
};

/**
 * @name: GmacLookupConfig
 * @msg: get gmac ctrl config
 * @return {*}
 * @param {u32} instanceId
 */
const GmacConfig *GmacLookupConfig(u32 instanceId)
{
    const GmacConfig *pConfig = NULL;
    u32 index;

    for (index = 0; index < (u32)GMAC_INSTANCE_NUM; index++)
    {
        if (gmacConfigTbl[index].instanceId == instanceId)
        {
            pConfig = &gmacConfigTbl[index];
            break;
        }
    }

    return pConfig;     
}